<!DOCTYPE html>
<html>
<head>
    <include file="Public:header" />
    <!-- jqgrid-->
    <link href="__ACSS__/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
    	<input id="id" class="hide" value="<{$id}>"/>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list"></table>
                            <div id="pager_list"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<!-- 全局js -->
<include file="Public:foot" />
<!-- jqGrid -->
<script src="__AJSPLUGINS__/jqgrid/i18n/grid.locale-cn.js?0820"></script>
<script src="__AJSPLUGINS__/jqgrid/jquery.jqGrid.min.js?0820"></script>
<!-- Page-Level Scripts -->
<script>
$(document).ready(function () {
	//初始化
    $.jgrid.defaults.styleUI = 'Bootstrap';
    $("#table_list").jqGrid({
    	url : '__URL__/getAllAddressData?id=' + $("#id").val(),
        datatype: "json",
        height: 450,
        autowidth: true,
        shrinkToFit: true,
        rowNum: 15,
        rowList: [10, 15, 30, 50],
        colNames : [ 'ID', '省', '市', '区', '详细地址', '学校', '联系人', '联系电话', '是否主地址', '创建时间' ], 
        colModel : [ {name : 'id',index : 'id'},
                     {name : 'province',index : 'province'},
                     {name : 'city',index : 'city'},
                     {name : 'area',index : 'area'},
                     {name : 'address',index : 'address'},
                     {name : 'school',index : 'school'},
                     {name : 'contact_name',index : 'contact_name'},
                     {name : 'contact_tel',index : 'contact_tel'},
                     {name : 'is_main',index : 'is_main',sortable : false,formatter : function(cellvalue, options, rowObject){
                    	 if(cellvalue == 1) {
                    		 content = '是';
                    	 }else if(cellvalue == 0) {
                    		 content = '否';
                    	 }
                    	 return content;
                	 }},
                	 {name : 'create_time',index : 'create_time',formatter: 'date',formatoptions: {srcformat:'u',newformat:'Y-m-d H:i:s'}}
                   ],
        pager: "#pager_list",
        viewrecords: true,
        hidegrid: false,
        sortname: "id",
        sortorder: "desc",
    });
 	// 设置按钮
    $("#table_list").jqGrid('navGrid', '#pager_list', {
        edit: false,
        add: false,
        del: false,
        search: false
    }, {
        height: 200,
        reloadAfterSubmit: true
    });
    // 添加适配响应
    $(window).bind('resize', function () {
        var width = $('.jqGrid_wrapper').width();
        $('#table_list').setGridWidth(width);
    });
    
});

//改
$("#detail").click(function() {
	var id = $("#table_list").jqGrid('getGridParam','selrow');
	if(id != null) {
		layerDialog("账户明细",'__URL__/detail?id='+id,"90%","250px",true);
	}else {
		layer.msg("您没有选取数据！");
	}
})

//重置密码
function resetPwd(id) {
	layer.confirm('密码将重置为 <font style="color:red;">000000</font></br>确定执行？', function(index){
    	var index = layer.load(2);
    	$.ajax({
			url:"__URL__/updateStatus",
			type:"post",
			data:{'user_id':id,'field':'password','islock':"670b14728ad9902aecba32e22fa4f6bd"},
			success:function(json){
				var data = eval("("+json+")");
				if(data.status == 1){
					layer.msg(data.info);
					$('#table_list').trigger("reloadGrid");
				}else{
					layer.msg(data.info);
				}
				layer.close(index);
			}
		})
	});
}
//锁定&解锁
function updateLock(id,islock) {
	layer.confirm('确定执行？', function(index){
    	var index = layer.load(2);
    	$.ajax({
			url:"__URL__/updateStatus",
			type:"post",
			data:{'user_id':id,'field':'islock','islock':islock},
			success:function(json){
				var data = eval("("+json+")");
				if(data.status == 1){
					layer.msg(data.info);
					$('#table_list').trigger("reloadGrid");
				}else{
					layer.msg(data.info);
				}
				layer.close(index);
			}
		})
	});
}
</script>
</html>